]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
magnifier: Include SSD when calculating screen coordinates for events
authorSebastian Keller <skeller@gnome.org>
Tue, 31 May 2022 16:18:45 +0000 (18:18 +0200)
committerMarge Bot <marge-bot@gnome.org>
Tue, 31 May 2022 18:55:18 +0000 (18:55 +0000)
When calculating the on screen coordinates of events from the window
relative coordinates, using the frame rect will include the decorations
added by the WM for SSD windows. This was causing the calculated
coordinates to be slightly off. Fix this by using the client rect for
SSD windows.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2319>

js/ui/magnifier.js

index 30e53398ab11271b0bd6eab9402b6ee6c65aab3a..44cdef0afbf61226d6dbfdc47dc677a165157592 100644 (file)
@@ -845,14 +845,18 @@ var ZoomRegion = class ZoomRegion {
             throw new Error(`Failed to validate parent window: ${e}`);
         }
 
-        const focusWindowRect = global.display.focus_window?.get_frame_rect();
-        if (!focusWindowRect)
+        const { focusWindow } = global.display;
+        if (!focusWindow)
             return null;
 
+        let windowRect = focusWindow.get_frame_rect();
+        if (!focusWindow.is_client_decorated())
+            windowRect = focusWindow.frame_rect_to_client_rect(windowRect);
+
         const scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
         const screenSpaceExtents = new Atspi.Rect({
-            x: focusWindowRect.x + (scaleFactor * extents.x),
-            y: focusWindowRect.y + (scaleFactor * extents.y),
+            x: windowRect.x + (scaleFactor * extents.x),
+            y: windowRect.y + (scaleFactor * extents.y),
             width: scaleFactor * extents.width,
             height: scaleFactor * extents.height,
         });